﻿<UserControl x:Class="MediaOwl.WebSearch.Views.BingWebSearchView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:ctrl="clr-namespace:MediaOwl.Common.ControlTemplates;assembly=MediaOwl.Common"
             mc:Ignorable="d"
             d:DesignHeight="569"
             d:DesignWidth="833">

    <UserControl.Resources>
        <DataTemplate x:Key="SearchResultItemTemplate">
            <toolkit:DockPanel Margin="5">
                <TextBlock toolkit:DockPanel.Dock="Top"
                           Text="{Binding Title}"
                           Style="{StaticResource Heading5}" />
                <TextBlock TextWrapping="Wrap"
                           Text="{Binding DisplayUrl}"
                           Style="{StaticResource ContentTextStyle}"
                           Foreground="{StaticResource CheckBoxBackgroundBrush}"
                           toolkit:DockPanel.Dock="Top"
                           HorizontalAlignment="Stretch"
                           Margin="2"
                           FontSize="12" />
                <TextBlock TextWrapping="Wrap"
                           Text="{Binding Description}"
                           Style="{StaticResource ContentTextStyle}"
                           Foreground="{StaticResource ControlForeground}"
                           toolkit:DockPanel.Dock="Top"
                           HorizontalAlignment="Stretch"
                           Margin="10,2,0,2"
                           FontSize="12" />
            </toolkit:DockPanel>
        </DataTemplate>
        <Style x:Key="SearchResultItemStyle"
               TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid d:DesignWidth="402"
                              d:DesignHeight="84"
                              Margin="5">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition From="MouseOver"
                                                          GeneratedDuration="0:0:0.4"
                                                          To="Normal">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CircleEase EasingMode="EaseIn" />
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                        <VisualTransition From="Normal"
                                                          GeneratedDuration="0:0:0.1"
                                                          To="MouseOver">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CircleEase EasingMode="EaseOut" />
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0"
                                                             To="0.3"
                                                             Storyboard.TargetProperty="(UIElement.Opacity)"
                                                             Storyboard.TargetName="rectangle"
                                                             d:IsOptimized="True" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle x:Name="rectangle"
                                       Fill="{StaticResource ControlBackgroundAltBrush}"
                                       Stroke="{StaticResource ControlDarkEdge}"
                                       RadiusX="1"
                                       RadiusY="1"
                                       Opacity="0" />
                            <ContentPresenter />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <ctrl:WorkitemControl BusyContext="{Binding CurrentBusyViewModel}"
                          DialogContext="{Binding ActiveDialog}">
        <toolkit:DockPanel Margin="5">

            <toolkit:DockPanel LastChildFill="False"
                               Margin="0,0,0,5"
                               toolkit:DockPanel.Dock="Top">
                <TextBlock x:Name="DisplayName"
                           TextWrapping="Wrap"
                           toolkit:DockPanel.Dock="Top"
                           Style="{StaticResource Heading2}"
                           Margin="0,0,0,10" />
                <TextBlock x:Name="SearchResultText"
                           Foreground="{StaticResource ControlForeground}"
                           MinHeight="20"
                           Margin="0,2,0,0"
                           toolkit:DockPanel.Dock="Bottom" />
                <TextBox x:Name="SearchText"
                         TextWrapping="Wrap"
                         Margin="0,0,10,0"
                         MinWidth="150"
                         VerticalAlignment="Top">
                    <i:Interaction.Triggers>
                        <ei:KeyTrigger Key="Enter">
                            <cal:ActionMessage MethodName="SearchShortCut" />
                        </ei:KeyTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
                <Button x:Name="SearchItems"
                        Content="Search"
                        Margin="0,0,10,0"
                        VerticalAlignment="Top" />
                <StackPanel Orientation="Horizontal"
                            HorizontalAlignment="Right"
                            toolkit:DockPanel.Dock="Right">
                    <Button x:Name="Previous"
                            Content="Previous"
                            d:LayoutOverrides="Height" />
                    <toolkit:NumericUpDown x:Name="ItemsPerPage"
                                           Increment="10"
                                           Minimum="1"
                                           Margin="5,0"
                                           Width="60" />
                    <Button x:Name="Next"
                            Content="Next"
                            d:LayoutOverrides="Height"
                            Margin="0" />
                </StackPanel>
            </toolkit:DockPanel>
            <ListBox x:Name="Results"
                     ItemTemplate="{StaticResource SearchResultItemTemplate}"
                     d:LayoutOverrides="Height"
                     Background="Transparent"
                     ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                     SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                     ItemContainerStyle="{StaticResource SearchResultItemStyle}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <cal:ActionMessage MethodName="Open" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </ListBox>

        </toolkit:DockPanel>
    </ctrl:WorkitemControl>
</UserControl>
